Imports System.Windows.Forms
Imports dao
 Imports System.Data
Imports DTO
Public Class CAPHOCBus
Inherits AbstractBus
 Public Sub New()
 End Sub
 Public Sub New(ByVal ConnectionString As KetNoiDto)
 ketnoi = ConnectionString
 End Sub
 #Region "Xử Lý" 
 Public Sub Them(ByVal Dto As CAPHOCDto)
 Dim Dao As New CAPHOCDao(ketnoi)
 Dao.Them(Dto)
 End Sub
 Public Sub Xoa( ByVal IDCAPHOC As System.Int32)
 Dim Dao As New CAPHOCDao(ketnoi)
 Dao.xoa(IDCAPHOC)
 End Sub
 Public Sub sua(ByVal Dto As CAPHOCDto)
 Dim Dao As New CAPHOCDao(ketnoi)
 Dao.sua(Dto)
 End Sub
 #End Region 
 Public Function LayBangTable() As DataTable
 Dim Dao As New CAPHOCDao(ketnoi)
 dao.laybang()
 Return Dao
 End Function
 Public Function LayBangTableIlist() As IList
 Dim Dao As New CAPHOCDao(ketnoi)
 Dim aList As New ArrayList 
 For i As Integer = 0 To Dao.Rows.Count - 1 
 Dim dtoCAPHOC As CAPHOCdto = LayBangDTo(i, Dao) 
 aList.Add(dtoCAPHOC)
 Next 
 Return aList 
 End Function
 Public Function LayBangTableSQL(ByVal sql As string) As DataTable
 Dim Dao As New  AbstractDao(sql,sql,ketnoi)
 Return Dao
 End Function
 Public Sub suaTENCAPHOC( ByVal TENCAPHOC as System.String, ByVal IDCAPHOC As System.Int32 )
 Dim dao As New CAPHOCDao(ketnoi)
 dao.suaTENCAPHOC(TENCAPHOC,IDCAPHOC)
 End Sub 
 Public Sub suaHOCPHI( ByVal HOCPHI as System.String, ByVal IDCAPHOC As System.Int32 )
 Dim dao As New CAPHOCDao(ketnoi)
 dao.suaHOCPHI(HOCPHI,IDCAPHOC)
 End Sub 
 Public Sub suaTRANGTHAI( ByVal TRANGTHAI as System.Int32, ByVal IDCAPHOC As System.Int32 )
 Dim dao As New CAPHOCDao(ketnoi)
 dao.suaTRANGTHAI(TRANGTHAI,IDCAPHOC)
 End Sub 
 Public Sub suaGHICHU( ByVal GHICHU as System.String, ByVal IDCAPHOC As System.Int32 )
 Dim dao As New CAPHOCDao(ketnoi)
 dao.suaGHICHU(GHICHU,IDCAPHOC)
 End Sub 
 Public Function LayBangTable( ByVal IDCAPHOC As System.Int32) As DataTable
 Dim Dao As New CAPHOCDao(IDCAPHOC,ketnoi)
 Return Dao
 End Function
 Public Function LayBangTableIlist( ByVal IDCAPHOC As System.Int32) As IList
 Dim Dao As New CAPHOCDao(IDCAPHOC,ketnoi)
 Dim aList As New ArrayList 
 For i As Integer = 0 To Dao.Rows.Count - 1 
 Dim dtoCAPHOC As CAPHOCdto = LayBangDTo(i, Dao) 
 aList.Add(dtoCAPHOC)
 Next 
 Return aList 
 End Function
 Public Function LayBangTableTheoIDCAPHOC (ByVal IDCAPHOC As System.Int32) As DataTable
 Dim Dao As New CAPHOCDao(ketnoi)
 Dao.layBangTheoIDCAPHOC(IDCAPHOC)
 Return Dao
 End Function
 Public Function LayBangTableTheoIDCAPHOC (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New CAPHOCDao(ketnoi)
 Dao.layBangTheoIDCAPHOC(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoIDCAPHOC (ByVal IDCAPHOC As System.Int32) 
 Dim Dao As New CAPHOCDao(ketnoi)
 Dao.XOABangTheoIDCAPHOC(IDCAPHOC)
 End sub
 Public Function LayBangTableTheoTENCAPHOC (ByVal TENCAPHOC As System.String) As DataTable
 Dim Dao As New CAPHOCDao(ketnoi)
 Dao.layBangTheoTENCAPHOC(TENCAPHOC)
 Return Dao
 End Function
 Public Function LayBangTableTheoTENCAPHOC_like (ByVal TENCAPHOC As System.String ) As DataTable
 Dim Dao As New CAPHOCDao(ketnoi)
 Dao.layBangTheoTENCAPHOC_like (TENCAPHOC)
 Return Dao
 End Function
 Public Function LayBangTableTheoTENCAPHOC (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New CAPHOCDao(ketnoi)
 Dao.layBangTheoTENCAPHOC(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoTENCAPHOC (ByVal TENCAPHOC As System.String) 
 Dim Dao As New CAPHOCDao(ketnoi)
 Dao.XOABangTheoTENCAPHOC(TENCAPHOC)
 End sub
 Public Function LayBangTableTheoHOCPHI (ByVal HOCPHI As System.String) As DataTable
 Dim Dao As New CAPHOCDao(ketnoi)
 Dao.layBangTheoHOCPHI(HOCPHI)
 Return Dao
 End Function
 Public Function LayBangTableTheoHOCPHI_like (ByVal HOCPHI As System.String ) As DataTable
 Dim Dao As New CAPHOCDao(ketnoi)
 Dao.layBangTheoHOCPHI_like (HOCPHI)
 Return Dao
 End Function
 Public Function LayBangTableTheoHOCPHI (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New CAPHOCDao(ketnoi)
 Dao.layBangTheoHOCPHI(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoHOCPHI (ByVal HOCPHI As System.String) 
 Dim Dao As New CAPHOCDao(ketnoi)
 Dao.XOABangTheoHOCPHI(HOCPHI)
 End sub
 Public Function LayBangTableTheoTRANGTHAI (ByVal TRANGTHAI As System.Int32) As DataTable
 Dim Dao As New CAPHOCDao(ketnoi)
 Dao.layBangTheoTRANGTHAI(TRANGTHAI)
 Return Dao
 End Function
 Public Function LayBangTableTheoTRANGTHAI (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New CAPHOCDao(ketnoi)
 Dao.layBangTheoTRANGTHAI(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoTRANGTHAI (ByVal TRANGTHAI As System.Int32) 
 Dim Dao As New CAPHOCDao(ketnoi)
 Dao.XOABangTheoTRANGTHAI(TRANGTHAI)
 End sub
 Public Function LayBangTableTheoGHICHU (ByVal GHICHU As System.String) As DataTable
 Dim Dao As New CAPHOCDao(ketnoi)
 Dao.layBangTheoGHICHU(GHICHU)
 Return Dao
 End Function
 Public Function LayBangTableTheoGHICHU_like (ByVal GHICHU As System.String ) As DataTable
 Dim Dao As New CAPHOCDao(ketnoi)
 Dao.layBangTheoGHICHU_like (GHICHU)
 Return Dao
 End Function
 Public Function LayBangTableTheoGHICHU (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New CAPHOCDao(ketnoi)
 Dao.layBangTheoGHICHU(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoGHICHU (ByVal GHICHU As System.String) 
 Dim Dao As New CAPHOCDao(ketnoi)
 Dao.XOABangTheoGHICHU(GHICHU)
 End sub
 Public Function LayBangDTo( ByVal IDCAPHOC As System.Int32) As CAPHOCdto
 Dim Dao As New CAPHOCDao(IDCAPHOC, ketnoi)
 Dim dto As New CAPHOCdto
 If Dao.Rows.Count<= 0 then Return dto
 Try
 If IsDBNull(Dao.Rows(0)("IDCAPHOC")) = False Then
 Dto.IDCAPHOC = Dao.Rows(0)("IDCAPHOC")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("CAPHOC.IDCAPHOC")) = False Then
 Dto.IDCAPHOC = Dao.Rows(0)("CAPHOC.IDCAPHOC")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("TENCAPHOC")) = False Then
 Dto.TENCAPHOC = Dao.Rows(0)("TENCAPHOC")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("CAPHOC.TENCAPHOC")) = False Then
 Dto.TENCAPHOC = Dao.Rows(0)("CAPHOC.TENCAPHOC")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("HOCPHI")) = False Then
 Dto.HOCPHI = Dao.Rows(0)("HOCPHI")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("CAPHOC.HOCPHI")) = False Then
 Dto.HOCPHI = Dao.Rows(0)("CAPHOC.HOCPHI")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("TRANGTHAI")) = False Then
 Dto.TRANGTHAI = Dao.Rows(0)("TRANGTHAI")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("CAPHOC.TRANGTHAI")) = False Then
 Dto.TRANGTHAI = Dao.Rows(0)("CAPHOC.TRANGTHAI")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("GHICHU")) = False Then
 Dto.GHICHU = Dao.Rows(0)("GHICHU")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("CAPHOC.GHICHU")) = False Then
 Dto.GHICHU = Dao.Rows(0)("CAPHOC.GHICHU")
 End if
Catch ex As Exception
End Try
 Return dto
 end function
 Public Function LayBangDTo(ByVal i As Integer, ByVal dao As DataTable) As CAPHOCdto
 Dim dto As New CAPHOCdto
 If Dao.Rows.Count<=0 then Return dto
 Try
 If IsDBNull(Dao.Rows(i)("IDCAPHOC")) = False Then
 Dto.IDCAPHOC = Dao.Rows(i)("IDCAPHOC")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("CAPHOC.IDCAPHOC")) = False Then
 Dto.IDCAPHOC = Dao.Rows(i)("CAPHOC.IDCAPHOC")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("TENCAPHOC")) = False Then
 Dto.TENCAPHOC = Dao.Rows(i)("TENCAPHOC")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("CAPHOC.TENCAPHOC")) = False Then
 Dto.TENCAPHOC = Dao.Rows(i)("CAPHOC.TENCAPHOC")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("HOCPHI")) = False Then
 Dto.HOCPHI = Dao.Rows(i)("HOCPHI")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("CAPHOC.HOCPHI")) = False Then
 Dto.HOCPHI = Dao.Rows(i)("CAPHOC.HOCPHI")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("TRANGTHAI")) = False Then
 Dto.TRANGTHAI = Dao.Rows(i)("TRANGTHAI")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("CAPHOC.TRANGTHAI")) = False Then
 Dto.TRANGTHAI = Dao.Rows(i)("CAPHOC.TRANGTHAI")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("GHICHU")) = False Then
 Dto.GHICHU = Dao.Rows(i)("GHICHU")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("CAPHOC.GHICHU")) = False Then
 Dto.GHICHU = Dao.Rows(i)("CAPHOC.GHICHU")
 End if
 Catch ex As Exception
 End Try
 Return dto
 end function
 Public Function LayBangDTo(ByVal dong As Integer, ByVal dao As DataGridView) As CAPHOCdto
 Dim dto As New CAPHOCdto
 If dao.Rows.Count <= 0 Then Return dto
 For cot As Integer = 0 To dao.Columns.Count - 1
 Try
 Dto.HoTro(dao.Columns(cot).DataPropertyName, dao.Item(cot, dong).Value)
 Catch ex As Exception
 End Try
 Next
 Return Dto
 End Function
 Public Function layBangNhieuTable() as Datatable
 Dim Dao As New CAPHOCDao(ketnoi)
 Dao.layBangNhieuTable()
 Return Dao
 End Function
 Public Sub Taotable()
 Dim Dao As New CAPHOCDao(ketnoi)
 Dao.TaoTable()
 End Sub
 End Class

